package top.starp.util;

//import java.sql.Date;
import java.util.Calendar;
import java.util.Date;

public class DateUtil {
    /**
     *  https://blog.csdn.net/u013781343/article/details/80693875
     * @param date
     * @return
     */
    public static Date getNextDay(Date date) {
//        if(date == null){
//            System.out.println("入参为空");
//            return null;
//        }
//        Calendar calendar = Calendar.getInstance();
//        calendar.setTime(date);
//
//        calendar.add(Calendar.DAY_OF_MONTH, +1);//明天
//        //calendar.add(Calendar.DAY_OF_MONTH, 0);//今天
//        calendar.add(Calendar.DAY_OF_MONTH, -1);//昨天
//        return calendar.getTime();
        return getDayDiffer(date,1);
    }

    public static Date getDayDiffer(Date date,int differ) {
        if(date == null){
            System.out.println("入参为空");
            return null;
        }
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);

//        calendar.add(Calendar.DAY_OF_MONTH, +1);//明天
        calendar.add(Calendar.DAY_OF_MONTH, differ);//明天
        //calendar.add(Calendar.DAY_OF_MONTH, 0);//今天
//        calendar.add(Calendar.DAY_OF_MONTH, -1);//昨天
        return calendar.getTime();
    }
}
